/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.events;

/**
 * <p>This is a subclass of XREEvent that represents the "onDynamicTransitionComplete" event. It defines some properties
 * specific to this event. Note that values of all custom properties are actually stored in the XREEvent#params
 * map.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
@SuppressWarnings("boxing")
public class XREVideoDynamicTransitionCompleteEvent extends XREResourceEvent {

    /**
     * <p>Represents the name of the "on dynamic transition complete" event.</p>
     *
     * <p>This is a string constant used by the user when setting the name of the event.</p>
     */
    public static final String ON_DYNAMIC_TRANSITION_COMPLETE_EVENT_NAME = "onDynamicTransitionComplete";

    /**
     * <p>Represents the name used to retrieve the max band width parameter.</p>
     */
    private static final String MAX_BAND_WIDTH = "maxBandWidth";

    /**
     * <p>Represents the name used to retrieve the current stream bit rate parameter.</p>
     */
    private static final String CURRENT_STREAM_BIT_RATE = "currentStreamBitRate";

    /**
     * <p>Represents the name used to retrieve the rendering index parameter.</p>
     */
    private static final String RENDERING_INDEX = "renderingIndex";

    /**
     * <p>Represents the name used to retrieve the reason parameter.</p>
     */
    private static final String REASON = "reason";

    /**
     * <p>Creates new instance of {@link XREVideoDynamicTransitionCompleteEvent} class.</p>
     */
    public XREVideoDynamicTransitionCompleteEvent() {
        // empty constructor
    }

    /**
     * <p>Retrieves the maximum measured bandwidth available to the video player.</p>
     *
     * @return the maximum measured bandwidth available to the video player
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getMaxBandWidth() {
        return getTypedParam(MAX_BAND_WIDTH, Double.class);
    }

    /**
     * <p>Sets the maximum measured bandwidth available to the video player.</p>
     *
     * @param maxBandWidth the maximum measured bandwidth available to the video player
     *
     * @throws IllegalStateException if params is null
     */
    public void setMaxBandWidth(double maxBandWidth) {
        setParam(MAX_BAND_WIDTH, maxBandWidth);
    }

    /**
     * <p>Retrieves the bitrate of the currently playing stream.</p>
     *
     * @return the bitrate of the currently playing stream
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public double getCurrentStreamBitRate() {
        return getTypedParam(CURRENT_STREAM_BIT_RATE, Double.class);
    }

    /**
     * <p>Sets the bitrate of the currently playing stream.</p>
     *
     * @param currentStreamBitRate the bitrate of the currently playing stream
     *
     * @throws IllegalStateException if params is null
     */
    public void setCurrentStreamBitRate(double currentStreamBitRate) {
        setParam(CURRENT_STREAM_BIT_RATE, currentStreamBitRate);
    }

    /**
     * <p>Retrieves the 0-based index of the current stream in the list of available streams.</p>
     *
     * @return the 0-based index of the current stream in the list of available streams
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public int getRenderingIndex() {
        return getTypedParam(RENDERING_INDEX, Integer.class);
    }

    /**
     * <p>Sets the 0-based index of the current stream in the list of available streams.</p>
     *
     * @param renderingIndex the 0-based index of the current stream in the list of available streams
     *
     * @throws IllegalStateException if params is null
     */
    public void setRenderingIndex(int renderingIndex) {
        setParam(RENDERING_INDEX, renderingIndex);
    }

    /**
     * <p>Retrieves the human readable string that describes why the stream switched.</p>
     *
     * @return the human readable string that describes why the stream switched
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public String getReason() {
        return getTypedParam(REASON, String.class);
    }

    /**
     * <p>Sets the human readable string that describes why the stream switched.</p>
     *
     * @param reason the human readable string that describes why the stream switched
     *
     * @throws IllegalStateException if params is null
     */
    public void setReason(String reason) {
        setParam(REASON, reason);
    }
}

